package TheGame.Graphics;

public class Sprite {
	
	public final int SIZE;
	private int x, y;
	public int[] pixels;
	private SpriteSheet sheet;
	
	public static Sprite grass = new Sprite(16, 0, 0, SpriteSheet.tiles);
	public static Sprite flower = new Sprite(16, 1, 0, SpriteSheet.tiles);
	public static Sprite rock = new Sprite(16, 2, 0, SpriteSheet.tiles);
	public static Sprite flower2 = new Sprite(16, 4, 0, SpriteSheet.tiles);
	
	public static Sprite fire = new Sprite(16, 6, 0, SpriteSheet.tiles);
	public static Sprite fire_purple = new Sprite(16, 6, 1, SpriteSheet.tiles);
	public static Sprite fire_out = new Sprite(16, 6, 2, SpriteSheet.tiles);
	
	public static Sprite ladder = new Sprite(16, 3, 0, SpriteSheet.tiles);
	public static Sprite bricks = new Sprite(16, 5, 0, SpriteSheet.tiles);
	public static Sprite floor = new Sprite(16, 7, 0, SpriteSheet.tiles);
	public static Sprite wall = new Sprite(16, 8, 0, SpriteSheet.tiles);
	public static Sprite side_wall = new Sprite(16, 10, 0, SpriteSheet.tiles);
	
	
	public static Sprite voidSprite = new Sprite(16, 0x1B87E0);
	
	public static Sprite deer = new Sprite(32, 0, 1, SpriteSheet.tiles);
	/*
	public static Sprite player0 = new Sprite(16, 0, 8, SpriteSheet.tiles);
	public static Sprite player1 = new Sprite(16, 1, 8, SpriteSheet.tiles);
	public static Sprite player2 = new Sprite(16, 0, 9, SpriteSheet.tiles);
	public static Sprite player3 = new Sprite(16, 1, 9, SpriteSheet.tiles);
	*/
	public static Sprite player_up = new Sprite(32, 0, 4, SpriteSheet.tiles);
	public static Sprite player_down = new Sprite(32, 2, 4, SpriteSheet.tiles);
	public static Sprite player_left = new Sprite(32, 3, 4, SpriteSheet.tiles);
	public static Sprite player_right = new Sprite(32, 1, 4, SpriteSheet.tiles);

	public static Sprite player_up_1 = new Sprite(32, 0, 5, SpriteSheet.tiles);
	public static Sprite player_up_2 = new Sprite(32, 0, 6, SpriteSheet.tiles);
	
	public static Sprite player_down_1 = new Sprite(32, 2, 5, SpriteSheet.tiles);
	public static Sprite player_down_2 = new Sprite(32, 2, 6, SpriteSheet.tiles);
	
	public static Sprite player_left_1 = new Sprite(32, 3, 5, SpriteSheet.tiles);
	public static Sprite player_left_2 = new Sprite(32, 3, 6, SpriteSheet.tiles);
	
	public static Sprite player_right_1 = new Sprite(32, 1, 5, SpriteSheet.tiles);
	public static Sprite player_right_2 = new Sprite(32, 1, 6, SpriteSheet.tiles);
	
	public static Sprite player_right_sword_1 = new Sprite(32, 4, 4, SpriteSheet.tiles);
	public static Sprite player_right_sword_2 = new Sprite(32, 4, 5, SpriteSheet.tiles);
	public static Sprite player_right_sword_3 = new Sprite(32, 4, 6, SpriteSheet.tiles);
	
	public static Sprite player_left_sword_1 = new Sprite(32, 5, 4, SpriteSheet.tiles);
	public static Sprite player_left_sword_2 = new Sprite(32, 5, 5, SpriteSheet.tiles);
	public static Sprite player_left_sword_3 = new Sprite(32, 5, 6, SpriteSheet.tiles);
	
	public Sprite(int size, int x, int y, SpriteSheet s){
		SIZE = size;
		pixels = new int[SIZE * SIZE];
		this.x = x * SIZE;
		this.y = y * SIZE;
		sheet = s;
		load();
	}
	
	public Sprite(int size, int color){
		SIZE = size;
		pixels = new int[SIZE * SIZE];
		for (int i = 0; i < pixels.length; i++){
			pixels[i] = color;
		}
	}
	
	private void load(){
		for (int y = 0; y < SIZE; y++){
			for (int x = 0; x < SIZE; x++){
				pixels[x + y * SIZE] = sheet.pixels[(this.x + x) + (this.y + y) * sheet.SIZE];
			}
		}
	}

}
